<?php

namespace App\Jobs;

use App\Models\StoreOrder;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;

class QueuedTest implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $orderData=$this->data;
        $time=strtotime(date('Y-m-d h:i:s'));
        foreach ($orderData as $v){
            if ($time-$v['add_time']>300){
                $upOrder=StoreOrder::where('status', 1)
                    ->update(['status'=>6]);
                Log::info($upOrder,[date('Y-m-d h:i:s')]);
            };
        }
    }
}
